package cn.ml.gaoJi.meiJu;

import java.util.Arrays;

public enum MyEnum {
    MONDAY("星期一",1),
    TUESDAY("星期二",2),
    WEDNESDAY("星期三",3),
    THURSDAY("星期四",4),
    FRIDAY("星期五",5),
    SATURDAY("星期六",6),
    SUNDAY("星期日",7);//记住要用分号结束

    private final String desc;//文字描述
    private final Integer code; //对应的代码

    /**
     * @deprecated 私有构造,防止被外部调用(枚举编译后默认是私有的)
     */
    MyEnum(String desc,Integer code){
        this.desc=desc;
        this.code=code;
    }


    public String getDesc(){
        return desc;
    }

    public int getCode(){
        return code;
    }

 public static void main(String[] args) {

        System.out.println("valuesOf方法："+MyEnum.valueOf("MONDAY"));
        MyEnum[] values = MyEnum.values();
        System.out.println("values方法(得到数组)："+ Arrays.toString(values));
        for (MyEnum myEnum:MyEnum.values()){
            System.out.println("name："+myEnum.name()+"," +
                    "desc："+myEnum.getDesc()+"," +
                    "code："+myEnum.getCode());
        }
    }
}
